package com.xcity.game.activity.luckdraw;

import com.xcity.game.item.ItemTemplate;

import naga.x.App;
import naga.x.game.template.TemplateService;
import naga.x.game.time.TimeUpdater;

public class BigLuckDrawLotteryRecord extends BigLuckDrawTemplate {

	protected BigLuckDrawTemplate proxy;
	protected int count;
	protected long time; // 中奖时间
	
	protected ItemTemplate item;
	
	public BigLuckDrawLotteryRecord() {}
	
	public BigLuckDrawLotteryRecord(BigLuckDrawTemplate template) {
		this.proxy = template;
		this.time = TimeUpdater.getInstance().now();
	}

	public long getTime() {
		return time;
	}

	public void setTime(long time) {
		this.time = time;
	}

	@Override
	public int getCount() {
		return count > 0 ? count : (proxy != null ? proxy.getCount() : 1);
	}
	
	public void setCount(int count) {
		this.count = count;
	}

	@Override
	public String getName() {
		return proxy != null ? proxy.getName() : (item != null ? item.getName() : "");
	}

	@Override
	public String getIcon() {
		return proxy != null ? proxy.getIcon() : (item != null ? item.getIcon() : "");
	}

	@Override
	public String getDesc() {
		return proxy != null ? proxy.getDesc() : (item != null ? item.getDesc() : "");
	}

	@Override
	public int getId() {
		return proxy != null ? proxy.getId() : (item != null ? item.getId() : BigLuckDrawTemplate.ID_DOUBLE_POINTS);
	}

	@Override
	public void setId(int id) {
		proxy = App.getApp().getServiceManager().get(TemplateService.class).get(BigLuckDrawTemplate.class, id);
		if (proxy == null) { // 策划删改配置表会为空
			item = App.getApp().getServiceManager().get(TemplateService.class).get(ItemTemplate.class, id);
		}
	}
	
}
